package cn.consult.sys.service.impl;

import cn.consult.sys.dao.TPlaceRoomDao;
import cn.consult.sys.entity.TPlaceFloor;
import cn.consult.sys.entity.TPlaceRoom;
import cn.consult.sys.service.TPlaceRoomService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 房间(TPlaceRoom)表服务实现类
 *
 * @author makejava
 * @since 2024-04-01 08:36:16
 */
@Service("tPlaceRoomService")
public class TPlaceRoomServiceImpl extends ServiceImpl<TPlaceRoomDao, TPlaceRoom> implements TPlaceRoomService {

    @Override
    public List<TPlaceRoom> getRoomByFloorId(Long roomId) {

        LambdaQueryWrapper<TPlaceRoom> roomLambdaQueryWrapper = new LambdaQueryWrapper<>();
        roomLambdaQueryWrapper.eq(TPlaceRoom::getRoomFloorid, roomId);


        List<TPlaceRoom> tPlaceRooms = this.baseMapper.selectList(roomLambdaQueryWrapper);

        return tPlaceRooms;
    }

    @Override
    public List<TPlaceRoom> selectByRoomNameOrNumber(Map<String, Object> params) {
        LambdaQueryWrapper<TPlaceRoom> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(params.get("roomSerialnumber") != null && params.get("roomSerialnumber") != "", TPlaceRoom::getRoomSerialnumber, params.get("roomSerialnumber"));
        queryWrapper.like(params.get("roomName") != null && params.get("roomName") != "", TPlaceRoom::getRoomName, params.get("roomName"));
        queryWrapper.eq(params.get("roomFloorid") != null && params.get("roomFloorid") != "", TPlaceRoom::getRoomFloorid, params.get("roomFloorid"));

        List<TPlaceRoom> tPlaceRooms = this.baseMapper.selectList(queryWrapper);
        if (tPlaceRooms != null) {
            return tPlaceRooms;
        }
        return null;
    }
}

